package main

type Student struct {
	Id     int64  `json:"Student_id" gorm:"size:128;default:(-);autoIncrement;primaryKey;comment:身份id"`
	Name   string `json:"name" gorm:"notnull;comment:名字"`
	DormId int64  `josn:"class_id" gorm:"size:128;comment:宿舍编号"` // 一对多

	CreatedAt int64 `gorm:"notnull;autoCreateTime;comment:创建时间"`
	UpdatedAt int64 `gorm:"notnull;autoUpdateTime;comment:更新时间"`
	DeletedAt int64 `gorm:"notnull;comment:删除时间"`
}

// 数据表设计原则上，一对多的关系直接将关系融入"多"表中
type Dormitory struct {
	Id     int64  `gorm:"primeryKey;size:128;comment:宿舍id"`
	Name   string `gorm:"size:128;comment:宿舍名字"`
	Number int    `gorm:"size:32;default:0;comment:宿舍人数"`

	CreatedAt int64 `gorm:"notnull;autoCreateTime;comment:创建时间"`
	UpdatedAt int64 `gorm:"notnull;autoUpdateTime;comment:更新时间"`
	DeletedAt int64 `gorm:"notnull;comment:删除时间"`
}

type Teacher struct {
	Id   int64  `gorm:"primeryKey;size:128;autoIncrement;comment:教师Id"`
	Name string `gorm:"nonull;size:128;column:teacher_name;comment:教师名称"`
	Age  int    `gorm:"size:32;column:age;comment:教师年龄"`
	// StudentId int64 `gorm:"size:128;comment:学生id"`

	CreatedAt int64 `gorm:"notnull;autoCreateTime;comment:创建时间"`
	UpdatedAt int64 `gorm:"notnull;autoUpdateTime;comment:更新时间"`
	DeletedAt int64 `gorm:"notnull;comment:删除时间"`
}

// 数据表设计上，多对多的关系定义另外的表
type Relation struct {
	Id        int64 `gorm:"primeryKey;size:128;comment:记录id"`
	StudentId int64 `gorm:"size:128;comment:学生id"`
	TeacherId int64 `gorm:"size:128;comment:教师id"`

	CreatedAt int64 `gorm:"notnull;autoCreateTime;comment:创建时间"`
	UpdatedAt int64 `gorm:"notnull;autoUpdateTime;comment:更新时间"`
	DeletedAt int64 `gorm:"notnull;comment:删除时间"`
}

// ==================================
